﻿<extend name="Public:office" />
<block name="title"><title>招聘管理</title></block>
<block name="header_styles">
    <link rel="stylesheet" href="__Public__/kindeditor/themes/default/default.css" />
    <style type="text/css">
        .main-wrapper .container {
            background-color: #ffffff;
        }

        .tooltip-inner {
            max-width: 400px;
        }

        .tooltip.right .tooltip-arrow {
            left: -5px;
            margin-top: -5px;
            border-width: 10px 10px 10px 0;
        }

        .ke-container {
            max-width: 100%;
        }
        span[data-valmsg-for]{
            display:none;
        }
        span.field-validation-error{
            display:inline-block;
        }
    </style>
</block>
<block name="header_scripts">

</block>
<block name="main">
    <div class="tabs-wrapper">
        <include file="Team:menu" />
        <div class="tab-content">
            <div class="tab-pane active" style="min-height: 500px;">
                <if condition="($pid gt 0) and ($adder eq 1)" name="adder" value="1"><a href="{:U('/Team/jobcondition', array('pid'=>$pid, 'id'=>0))}" class="btn btn-default btn-add pull-right"><i class="fa fa-plus"></i>&nbsp;添加职位</a></if>
                <div>
                    <if condition="$creater eq 1">
                        <h5>
                            <strong><gt name="pid" value="0">你的项目要招募哪些岗位，可以在这里发布或删除<else />当前无项目，请先创建项目</gt></strong>
                        </h5>
                        <else />
                        <h5>
                            <strong>你所在项目正在招募哪些岗位，都在这里列出</strong>
                        </h5>
                    </if>
                </div>
                <br />
                <div class="joblist" id="waterfall">
                    <ul class="waterfall-list">
                        <volist name="jobs" id="job">
                            <li>
                                <div class="panel panel-green">
                                    <div class="panel-heading">
                                        <span class="pull-right">空缺：{$job['num']-$job['datastate']}</span>
                                        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse{$job.id}" aria-expanded="true" aria-controls="collapse{$job.id}">{$job.name}</a>
                                    </div>
                                    <div id="collapse{$job.id}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                                        <div class="panel-body">
                                            <p>
                                                <b>数量</b><span>&nbsp;&nbsp;{$job.num}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                            </p>
                                            <if condition="$job.instalment eq 1">
                                            <p>
                                                <b>薪酬</b>&nbsp;&nbsp;
                                                <span>单期&nbsp;{$job.salary}</span>
                                                <span href="javascript:void(0);" class="tuo-guang <gt name='job.moneyin' value='0'>active</gt>" style="border-radius: 5px;">{$job.moneyin|toTuoguanDesc}</span>
                                            </p>
                                            <elseif condition="$job.instalment eq 2" />
                                            <p>
                                                <b>薪酬</b>&nbsp;&nbsp;
                                                <span>分期</span>
                                            </p>
                                            <volist name="job['instals']" id="instal" key="i">
                                                <p>
                                                    <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;第{$i}期&nbsp;{$instal['amount']}&nbsp;&nbsp;</span>
                                                    <span href="javascript:void(0);" class="tuo-guang <gt name='job.moneyin' value='0'>active</gt>" style="border-radius: 5px;">{$instal['moneyin']|toTuoguanDesc}</span>
                                                </p>
                                            </volist>
                                            </if>
                                            <p><b>工作内容</b></p>
                                            {$job.zhize|htmlspecialchars_decode}
                                            <p style="font-style: italic;color: #9f9f9f">创建时间:&nbsp;{$job.ctime|toTime=###,'Y-m-d'}</p>
                                            <eq name="deler" value="1">
                                                <a href="javascript:void(0);" data-id="{$job.id}" data-type="{$job.datastate}" class="btn btn-danger deljob">删除</a>
                                                <a href="{:U('/Team/jobcondition', array('pid'=>$pid, 'id'=>$job['id']))}" class="editjob btn btn-green">编辑</a>
                                            </eq>
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </volist>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div style="display: none;">
        <div id="tooltipcontent2" class="tooltipcontent2">
            <div>
                <div class="tooltip-title">资金托管</div>
                <div class="tooltip-body">
                    <p>
                        {$tip}
                    </p>
                    您可以通过如下方式将资金交予般若虾托管。<br />
                    &nbsp;&nbsp;-联系般若虾的客服，客服会指导您。<br /><br />
                    <strong>客服QQ：</strong>__SERVICE_QQ__<br />
                    <strong>电话：</strong>__SERVICE_TEL__
                </div>
            </div>
        </div>
    </div>
</block>
<block name="footer_scripts">
    <script type="text/javascript" src="__Public__/kindeditor/kindeditor-all-min.js"></script>
    <script type="text/javascript" src="__Public__/kindeditor/lang/zh_CN.js"></script>
    <script type="text/javascript">
        require(["jquery", "modules/message", "jquery.fancybox"], function ($, message) {

            $(".editjob,.btn-add").fancybox({
                type: "ajax",
                padding: 0,
                autoSize: true,
                fitToView: false,
                autoResize: true,
                scrolling: 'no',
                width: 600,
                closeBtn: false
            });

            $(".deljob").on("click", function () {

                var type = $(this).data("type");
                var id = $(this).data("id");

                if (type > 0) {
                    message.alert({ content: '该职位有员工在职，不能删除' });
                    return false;
                }

                message.confirm({
                    'content': "确定要删除这个职位吗？",
                    'sure': function () {
                        message.close();
                        var url = "{:U('/Team/job_del')}";
                        $.post(url, { id: id }, function (data) {
                            var vdata = eval(data);
                            if (vdata.success == 1) {
                                message.alert({ content: '删除成功', sure: function () { window.location.reload(); } });
                            } else {
                                message.alert({ content: vdata.msg });
                            }
                        }, 'json');
                        return false;
                    }
                });
            });

            var margin = 10;
            var li = $("ul.waterfall-list li");
            var li_W = li[0].offsetWidth + margin;

            function waterfall() {
                var h = [];
                var n = document.getElementById("waterfall").offsetWidth / li_W | 0;
                for (var i = 0; i < li.length; i++) {
                    li_H = li[i].offsetHeight;
                    if (i < n) {
                        h[i] = li_H;
                        li.eq(i).css("top", 0);
                        if (i * li_W > li_W - margin) {
                            li.eq(i).css("left", i * li_W + 10);
                        } else {
                            li.eq(i).css("left", i * li_W);
                        }
                    }
                    else {
                        min_H = Math.min.apply(null, h);
                        minKey = getarraykey(h, min_H);
                        h[minKey] += li_H + margin;
                        li.eq(i).css("top", min_H + margin);

                        if (minKey * li_W > li_W - margin) {
                            li.eq(i).css("left", minKey * li_W + 10);
                        } else {
                            li.eq(i).css("left", minKey * li_W);
                        }
                    }
                }

                var maxHeight = 0;
                $("ul.waterfall-list li").each(function () {
                    var position = $(this).offset();
                    var height = $(this).outerHeight();
                    if (maxHeight < position.top + height) {
                        maxHeight = position.top + height;
                    }
                });
                $("#waterfall").height(maxHeight);
            }

            function getarraykey(s, v) { for (k in s) { if (s[k] == v) { return k; } } }

            window.onload = function () { waterfall(); };
            window.onresize = function () { waterfall(); };

            $(function () {

                waterfall();

                $(".tuo-guang").click(function () {
                    $.fancybox.open("#tooltipcontent2", {
                        closeBtn: false,
                        padding: 0,
                        type: 'inline',
                        width: 300,
                        fixToView: true,
                        scrolling: 'no',
                        wrapCSS: 'tooltip-wrap'
                    });
                });
            });
        });
       
    </script>

</block>
